﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GameSite.Models;

namespace GameSite.Controllers
{
    public class ServiceController : Controller
    {
        private GameA4Context dbContext = new GameA4Context();

        public ServiceController()
        {
            GlobalViewModel.CacheService(ViewBag);
        }

        public ActionResult Index()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult Terms()
        {

            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult Privacy()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult Contact()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult FAQ()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult Account()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult Security()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult Pay()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult Game()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult Ban()
        {
            return View(GlobalViewModel.GameBanInfo);
        }

        public ActionResult Unban()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult Disclaimer()
        {
            return View(GlobalViewModel.ConfigModel);
        }

        public ActionResult ContactNote()
        {
            var model = new ContactNote()
            {
                CreateTime = DateTime.Now,
            };

            return View(model);
        }

        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult ContactNote(ContactNote model)
        {
            if (ModelState.IsValid)
            {
                dbContext.ContactNote.Add(model);
                dbContext.SaveChanges();
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }

        protected override void Dispose(bool disposing)
        {
            dbContext.Dispose();
            base.Dispose(disposing);
        }
    }
}